﻿using System.Windows.Forms;
using System.Drawing;
using Library.Util;
using Library.Winform.Draw.Tools;

namespace Library.Winform.Draw {
  public interface IDrawContainer : IStreamSerialization {
    /// <summary>
    /// Retrieves the cursor that will be displayed when the mouse is over this
    ///     control.
    /// </summary>
    Cursor Cursor { get; set; }
    /// <summary>
    /// Forces the control to invalidate and immediately
    ///     repaint itself and any children.
    /// </summary>
    void Refresh();
    /// <summary>
    /// Forces the control to redraw at determine position. (x, y) include ScrollOffset
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="width"></param>
    /// <param name="height"></param>
    void Update(int x, int y, int width, int height);
    /// <summary>
    /// Get all graphics of this controls
    /// </summary>
    GraphicsCollection GraphicsList { get; }

    /// <summary>
    /// Indicates whether the control has captured the mouse.
    /// </summary>
    bool Capture { get; set; }

    /// <summary>
    /// offset position for draw, to calculate client position, all child have to moving it position with offset
    /// </summary>
    Point ScrollOffset { get; }
    /// <summary>
    /// Computes the location of the client rectangle with scroll offset r in screen coords.
    /// </summary>
    /// <param name="rectangle"></param>
    /// <returns></returns>
    Rectangle RectangleToScreen(Rectangle rectangle);
    /// <summary>
    /// Active tool draw
    /// </summary>
    IToolGraphic ActiveToolDraw { get; set; }
    /// <summary>
    /// select all object draw with determine parameter
    /// </summary>
    /// <param name="isSelect">true: select all otherwise: unselect all</param>
    void SelectAll(bool isSelect);
    /// <summary>
    /// add object to container
    /// </summary>
    /// <param name="objectDraw"></param>
    void AddObjectDraw(ObjectDraw objectDraw);
    /// <summary>
    /// insert object to container
    /// </summary>
    /// <param name="index"></param>
    /// <param name="objectDraw"></param>
    void InsertObjectDraw(int index, ObjectDraw objectDraw);
    /// <summary>
    /// select selected object
    /// </summary>
    /// <returns></returns>
    SelectedDrawEnumerable GetSelected();
    /// <summary>
    /// select objects in rectangle (rectange contain scroll offset)
    /// </summary>
    /// <param name="rectangle"></param>
    void SelectInRectangle(Rectangle rectangle);
    /// <summary>
    /// remove object
    /// </summary>
    /// <param name="objectDraw"></param>
    void Remove(ObjectDraw objectDraw);
		/// <summary>
		/// Clear all object draw
		/// </summary>
  	void Clear();
    /// <summary>
    /// find object in point
    /// </summary>
    /// <param name="e"></param>
    /// <returns></returns>
    ObjectDraw FindDraw(ScrollMouseEventArgs e);
    /// <summary>
    /// find object in point
    /// </summary>
    /// <param name="pointWithScrollOffset"></param>
    /// <returns></returns>
    ObjectDraw FindDraw(Point pointWithScrollOffset);

    /// <summary>
    /// Computes the location of the screen rectangle r in client coords.
    /// </summary>
    /// <param name="r"></param>
    /// <returns>include scroll offset</returns>
    Rectangle RectangleToClient(Rectangle r);
    /// <summary>
    /// Create graphics
    /// </summary>
    /// <returns></returns>
    Graphics CreateGraphics();
    /// <summary>
    /// Group determine items
    /// </summary>
    /// <param name="items"></param>
    void Group(params ObjectDraw[] items);
  }
}
